package com.ynkbny.tasks;

import com.ynkbny.aspect.TaskOperationLog;
import com.ynkbny.service.BaseJob;
import com.ynkbny.service.EnterpriseService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.*;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author zelin.wang
 * @description 定时拉取企业数据
 * @date 11/17/2023
 */
@Slf4j
@Component
@PersistJobDataAfterExecution
@DisallowConcurrentExecution
public class EnterpriseInfo implements BaseJob {
    @Resource
    EnterpriseService enterpriseService;
    @Override
    @TaskOperationLog(description = "定时拉取企业数据")
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        log.info("自动任务：‘拉取企业数据 开始");

        //传递的参数
        JobDataMap data = jobExecutionContext.getTrigger().getJobDataMap();

        Object enterpriseCode = data.get("invokeParam");
        enterpriseService.upDateEnterpriseInfo(String.valueOf(enterpriseCode));
        log.info("自动任务：‘拉取企业数据 结束");
    }
}
